package API.String.Practises;
import java.util.Scanner;

public class NumToRoMa {
    public static void main(String[] args) {
        //输入数字
        Scanner sc = new Scanner(System.in);
        String result = sc.next();
        //检查输入的数据
        if(checkStr(result)){
            System.out.println(NumStrToRoMaStr(result));
        }else{
            System.out.println("输入错误！");
        }
    }

    //此方法用于检测输入的数字是否有误
    public static boolean checkStr(String str){
        if(str.length() > 9)
            return false;
        //检测输入的数据是否有除数字以外的数据，有则返回false
        for (int i = 0; i < str.length(); i++) {
            char check = str.charAt(i);
            if(check < '0' || check > '9')
                return false;
        }
        return true;
    }

    //此方法用于转换输入的数据
    public static String NumStrToRoMaStr(String numStr){
        String[] RoMa = {"","Ⅰ","Ⅱ","Ⅲ","Ⅳ","Ⅴ","Ⅵ","Ⅶ","Ⅷ","Ⅸ"};
        StringBuilder result = new StringBuilder();
        //根据传入的numStr向result传入古罗马数字符号
        for (int i = 0; i < numStr.length(); i++) {
            result.append(RoMa[(numStr.charAt(i) - '0')]);
        }
        return result.toString();
    }
}
